package thread;

/**
 * Created with IntelliJ IDEA.
 * Description: 等待线程join();
 * User: 王圆豪
 * Date: 2025-04-23
 * Time: 21:18
 */
public class Demo12 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(()->{
            for (int i = 0; i < 3000; i++) {
                System.out.println("Hello thread!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("thread线程结束！");
        });

        thread.start();
        Thread.sleep(1000);
        thread.join(5000);
        System.out.println("mian线程结束！");
    }
}
